<?php
require './configs/config.php';
//require './models/DB.class.php';
//
//require './controllers/indexController.php';
//require './controllers/userController.php';
//require './controllers/goodsController.php';

function test_autoload($classname)
{
    //    var_dump($classname);
    if(file_exists('./models/'.$classname.'.class.php')){
        require './models/'.$classname.'.class.php';
    }else if(file_exists('./controllers/'.$classname.'.php')){
        require './controllers/'.$classname.'.php';
    }else{
        header('HTTP/1.0 404 not found');
        echo '<h1> 404 NOt Found</h1>';
        exit;
    }
}

require './libs/Smarty.class.php';

// 将页面的__autoload 注册成test_autoload
spl_autoload_register('test_autoload');
//$smarty = new Smarty();

// 控制器名
$c = (!empty($_GET['c'])) ? $_GET['c'] : 'index';
$a = (!empty($_GET['a'])) ? $_GET['a'] : 'index';

// 拼接控制器名
$classname = $c . 'Controller';
// 实例化类
$data = new $classname();

// 调用方法
$data->$a();